#!/usr/bin/python
# -*- coding: UTF-8 -*-
# author: wangxiaoming 2021-11-16
# desc: thermal测试类

import enum
import unittest
import os
import time
import struct
from ctypes import *
from mainunit_common import *
from mainunit_api import *




class testself_tp_drv(unittest.TestCase):
    def data_callback(self, tp_data, tp_len):
        print(f'\ttp_len={tp_len}')
    
    def error_callback(self, err):
        print(f'\terr={err}')
        
    def testself1_tp_drv_value(self):
        print(f'\t==================================')
        expected=ECODE_OK
        
        erro_cb_obj = ErrorCallBack(self.error_callback)
        data_cb_obj = DataCallBack(self.data_callback)
        
        ret = tp_drv_init()
        print(f'\tstep. call api: tp_drv_init, actual value={ret}, expected value={expected}')
        self.assertEqual(ret, expected)
        
        #tp start
        ret = tp_drv_start(data_cb_obj,erro_cb_obj)        
        print(f'\tstep. call api: tp_drv_start, actual value={ret}, expected value={expected}')		
        self.assertEqual(ret, expected)
        
        txt = sp_input(f"\n\tPLEASE TOUCH TP AND CHECK TP BACKLIGHT AFTER PRESSING ANY KEY TO CONTINUE\n")        
        
        ret = tp_drv_stop()
        print(f'\tstep. call api: tp_drv_stop, actual value={ret}, expected value={expected}')		
        self.assertEqual(ret, expected)
        
        txt = sp_input(f"\n\tPLEASE TOUCH TP AND CHECK TP BACKLIGHT AFTER PRESSING ANY KEY TO CONTINUE\n")        
            
        ret = tp_drv_uinit()
        print(f'\tstep. call api: tp_drv_uinit, actual value={ret}, expected value={expected}')
        self.assertEqual(ret, expected)
        
        print('\t**********************************')    
